home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / challenge / 12.09-Sep96 / Testcode96.09R1.sit.hqx / Testcode96.09R1 / 4 MiscByteCodes / MiscByteCodes.java < prev    next >
Text File  |  1996-08-20  |  1KB  |  89 lines

  1.  
  2. import java.applet.Applet;
  3.  
  4.  
  5. public class MiscByteCodes extends Applet
  6. {
  7.     
  8.     int localVar;
  9.     
  10.     public void start()
  11.     {
  12.         int returnVal = myTest();
  13.         System.out.println( "Correct result is "+Integer.toString(returnVal ) );
  14.     }
  15.     
  16.     private int myNonVirtualMethod()
  17.     {
  18.         return localVar+1;
  19.     }
  20.  
  21.     public int myTest()
  22.     {
  23.         int result;
  24.         int i1 = 10;
  25.         int i2 = 12;
  26.         int i3 = 15;
  27.         int i4;
  28.         short s1 = 20;
  29.         short s2 = 22;
  30.         short s3 = 25;
  31.         short s4;
  32.         short s5 = 3;
  33.         byte b1 = 19;
  34.         byte b2 = 24;
  35.         byte b3 = 30;
  36.         byte b4;
  37.         char c1,c3;
  38.         char c2 = 'y';
  39.         
  40.         
  41.         i4 = i1+i2;
  42.         i4 -= i3;
  43.         i4 *= i1;
  44.         i4 /= 3;
  45.         i4 %= 17;
  46.         
  47.         s4 = (short)(s1+s2);
  48.         
  49.         b4 = (byte)(b1+b2-b3);
  50.         
  51.         c1 = 'x';
  52.         if (c1==c2) c3 = 'y';
  53.         else c3 = 'n';
  54.         if (c1>c2) c3 = 'y';
  55.         else c3 = 'n';
  56.         if (c1<c2) c3 = 'y';
  57.         else c3 = 'n';
  58.         if (c1<=c2) c3 = 'y';
  59.         else c3 = 'n';
  60.         if (c1>=c2) c3 = 'y';
  61.         else c3 = 'n';
  62.         if (c1!=c2) c3 = 'y';
  63.         else c3 = 'n';
  64.         
  65.         i4 <<=2;
  66.         i4>>=3;
  67.         b4>>=2;
  68.         s4<<=3;
  69.         s4>>=2;
  70.         
  71.         i2 = i3&i4;
  72.         ++i2;    // misalign next switch statement
  73.         
  74.         switch (i2) {
  75.             case 0: i2 +=1;
  76.             case 1: i2 +=2;
  77.             case 2: i2 +=4;
  78.             default: i2+=8;
  79.         }
  80.         
  81.         localVar = i2;
  82.         i2 += myNonVirtualMethod();
  83.         
  84.         result = i4+b4+s4+i2;
  85.         
  86.         return result;
  87.     }
  88. }
  89.